<template>

  <div class="app-container">

    <h2 style="text-align: center;">发布新资产</h2>

    <el-steps :active="2" process-status="wait" align-center style="margin-bottom: 40px;">
        <el-step title="填写资产信息" icon="el-icon-edit"></el-step>
        <el-step title="最终发布" icon="el-icon-upload"></el-step>
    </el-steps>

    <div class="ccInfo">
      <img :src="assetPublish.cover">
      <div class="main">
        <h2>{{ assetPublish.title }}</h2>
        <p><span>所属分类：{{ assetPublish.categoryLevelOne }} — {{ assetPublish.categoryLevelTwo }}</span></p>
        <div>残值率：{{assetPublish.netSalvage}}%</div>
        <div>使用年限：{{assetPublish.year}}年</div>
        <div>价格：{{assetPublish.price}}元</div>
        <div>折旧计算方法：{{assetPublish.method == 1 ? "年限平均法" : "双倍余额递减法"}}</div>
        <div>简介：<div v-html="assetPublish.description"></div></div>
      </div>
    </div>

    <div>
      <el-button @click="previous">返回修改</el-button>
      <el-button :disabled="saveBtnDisabled" type="primary" @click="publish">发布资产</el-button>
    </div>
  </div>
</template>

<script>
import asset from '@/api/manager/asset'
  export default {
    data() {
      return {
        saveBtnDisabled: false,assetId:''
        ,assetPublish:{}
      };
    },
    created(){
       if(this.$route.params && this.$route.params.id){
          this.assetId = this.$route.params.id
        }

       this.getAssetPUblishId()
    },
    methods: {
     getAssetPUblishId(){
        asset.getPublishAssetInfo(this.assetId)
        .then(res => {
          this.assetPublish = res.data.publishAsset
        })
      },
        previous() {
         this.$router.push({path:'/asset/info/' + this.assetId})
      },
        next() {
         this.$router.push({path:'/asset/list'})
      },
        publish(){
          asset.publishAssetInfo(this.assetId)
            .then(res =>{
              this.$message({
                    type:'success',
                    message: '发布成功'
                })

              this.$router.push({
                    path:'/asset/list'
                })
            })
        }
    }
  }
</script>

<style scoped>
.ccInfo {
    background: #f5f5f5;
    padding: 20px;
    overflow: hidden;
    border: 1px dashed #DDD;
    margin-bottom: 40px;
    position: relative;
}
.ccInfo img {
    background: #d6d6d6;
    width: 500px;
    height: 278px;
    display: block;
    float: left;
    border: none;
}
.ccInfo .main {
    margin-left: 520px;
}

.ccInfo .main h2 {
    font-size: 28px;
    margin-bottom: 30px;
    line-height: 1;
    font-weight: normal;
}
.ccInfo .main p {
    margin-bottom: 10px;
    word-wrap: break-word;
    line-height: 24px;
    max-height: 48px;
    overflow: hidden;
}

.ccInfo .main p {
    margin-bottom: 10px;
    word-wrap: break-word;
    line-height: 24px;
    max-height: 48px;
    overflow: hidden;
}
.ccInfo .main h3 {
    left: 540px;
    bottom: 20px;
    line-height: 1;
    font-size: 28px;
    color: #d32f24;
    font-weight: normal;
    position: absolute;
}
</style>
